import java.util.HashMap;

public class LeetCode3138 {
    public static int minAnagramLength(String s) {
    HashMap<Character, Integer> map = new HashMap<>();
    int maxLength = 0;
    int begin = 0;
    for(int i = 0; i < s.length(); i++){
        char c = s.charAt(i);
        if(map.containsKey(c)){
            begin = Math.max(maxLength, map.get(c)+1);
            map.put(c, i);
        }else {
            map.put(c, i);
        }
        maxLength = Math.max(maxLength, i - begin + 1);
    }
    return maxLength;
    }

    public static void main(String[] args) {
        System.out.println(minAnagramLength("aabbb"));
    }
}
